use RD4_DWCR
--select top (1000) * from JDEPYEmployeeTransactionHist
--where AddressNumber = 103558

--select top (100) * FROM JDEPYEmployeeMasterInfo


select top(500) * from JDEPYDBATransactionDetailHist
where AddressNumber = 103558
and year(DatePayCheck)<year('2013')
and DBACode='3899'
order by DatePayCheck desc


select count(*) from JDEPYEmployeeTransactionHist


select year(DatePayPeriodEnding), isnull(DatePayPeriodEnding, 0) From JDEPYDBATransactionDetailHist 
where year(DatePayPeriodEnding) < 2003 or year(DatePayPeriodEnding)>2013
Group by Year(DatePayPeriodEnding), DatePayPeriodEnding

select distinct (cast(DatePayPeriodEnding as date)) from JDEPYDBATransactionDetailHist
select distinct(CompanyNumber) from JDEPYEmployeeTransactionHist

select * FROM JDEPYEmployeeTransactionHist where CompanyNumber not in ('00800', '00500')

update JDEPYEmployeeTransactionHist set CompanyNumber='00800' where CompanyNumber not in ('00800', '00500')

use RD_PayrollMart
select top 100 * FROM Payroll_Star_Facts

select top 100 * FROM Payroll_Star_Employee